package com.ww.springboot.boot.config;


import com.ww.springboot.boot.util.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cache.CacheManager;
import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component;

/**
 * @author : liw
 * @date : 2020/11/18 19:34
 */
@Component
@Slf4j
public class CacheEvictListener implements MessageListener {


    private static CacheManager cacheManager;


    /**
     * 获取缓存工具
     *
     * @return CacheManager
     */
    private static CacheManager getCacheManager() {
        if (cacheManager == null) {
            cacheManager = SpringUtil.getBean(CacheManager.class);
        }
        return cacheManager;
    }

    @Override
    public void onMessage(Message message, byte[] pattern) {
        System.out.println("--------收到消息!-------");
    }


}
